<template>
  <min-dialog-box
  :dialogData="dialogData"
  @endBtnEvent="endBtnEvent"
  @leaveBtnEvent="leaveBtnEvent"
  @cancelBtnEvent="cancelBtnEvent"
  ></min-dialog-box>
</template>

<script>
import { sendSock } from '@/utils/socketSend'

export default {
  data () {
    return {
    }
  },
  computed: {
    // 身份
    identity () {
      return this.tools.conference.isHost(this.tools.getUserId())
    },
    dialogData () {
      const data = {}
      switch (this.identity) {
        case true: {
          data.mainTips = ['如果您不想结束会议，', '请在离开会议前指定新的主持人']
          data.btnList = [{
            name: '结束会议',
            color: 'blue',
            type: 'end'
          }, {
            name: '离开会议',
            color: 'blue',
            type: 'leave'
          }, {
            name: '取消',
            color: 'white',
            type: 'cancel'
          }]
          break
        }
        case false: {
          data.mainTips = ['您确定离开会议吗？']
          data.btnList = [{
            name: '离开会议',
            color: 'blue',
            type: 'leave'
          }, {
            name: '取消',
            color: 'white',
            type: 'cancel'
          }]
          break
        }
      }
      return data
    }
  },
  methods: {
    // 结束会议
    endBtnEvent () {
      sendSock({
        type: '4.1.30',
        body: {
          cf_id: this.$store.state.conferenceRoom.cf_id
        }
      })
    },
    // 离开会议
    leaveBtnEvent () {
      sendSock({
        type: '4.1.4',
        body: {
          cf_id: this.$store.state.conferenceRoom.cf_id
        }
      })
      this.$store.commit('conferenceRoom/close_allPeer')
      this.$store.commit('conferenceRoom/reset_state')
      this.$router.push('/conference/agendaCf/main')
    },
    cancelBtnEvent () {
      this.$emit('closeEndDialog')
    }
  }
}
</script>

<style>

</style>
